from google.appengine.api import images

FULL_WIDTH = 600
FULL_HEIGHT = 600
THUMB_WIDTH = 120
THUMB_HEIGHT = 120

def get_full_size_image(imageData):
    imgFull = images.Image(imageData)
    if imgFull.width > FULL_WIDTH or imgFull.height > FULL_HEIGHT:
        imgFull.resize(width=FULL_WIDTH, height=FULL_HEIGHT)
        imgFullData = imgFull.execute_transforms(output_encoding=images.JPEG)
        imgFull = images.Image(imgFullData)
    
    watermark_file = open('watermark.png', "r")
    return images.composite(
        inputs=[(imgFullData, 0, 0, 1.0, images.TOP_LEFT),
            (watermark_file.read(), 0, 0, 1.0, images.BOTTOM_RIGHT)],
        width=imgFull.width,
        height=imgFull.height,
        output_encoding=images.JPEG
    )
    
def get_thumbnail_image(imageData):
    imgThumb = images.Image(imageData)
    imgThumb.resize(width=120, height=120)
    return imgThumb.execute_transforms(output_encoding=images.JPEG)